if(DOXYGEN_FOUND AND NOT CMAKE_VERSION VERSION_LESS 3.9)
    if(UNIX)
        execute_process(COMMAND date "+%b %d, %Y"
            OUTPUT_VARIABLE OMPL_RELEASE_DATE
            OUTPUT_STRIP_TRAILING_WHITESPACE)
        set(OMPL_RELEASE_DATE "${OMPL_RELEASE_DATE}" PARENT_SCOPE)
    endif()
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/header.html.in"
        "${CMAKE_BINARY_DIR}/doc/header.html")
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/markdown/download.md.in"
        "${CMAKE_BINARY_DIR}/doc/ompl_download.md")
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/markdown/mainpage.md.in"
        "${CMAKE_BINARY_DIR}/doc/mainpage.md")
    file(READ "${CMAKE_CURRENT_SOURCE_DIR}/images/ompl.svg" OMPLSVG)
    file(READ "${CMAKE_CURRENT_SOURCE_DIR}/images/cforest.svg" CFORESTSVG)
    file(READ "${CMAKE_CURRENT_SOURCE_DIR}/images/cforest_sampler.svg" CFOREST_SAMPLERSVG)
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/markdown/api_overview.md.in"
        "${CMAKE_BINARY_DIR}/doc/api_overview.md")
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/markdown/CForest.md.in"
        "${CMAKE_BINARY_DIR}/doc/CForest.md")

    set(DOXYGEN_STRIP_FROM_PATH "${CMAKE_SOURCE_DIR};${CMAKE_SOURCE_DIR}/src;${CMAKE_SOURCE_DIR}/ompl/src" PARENT_SCOPE)
    set(DOXYGEN_STRIP_FROM_INC_PATH "${CMAKE_SOURCE_DIR}/src;${CMAKE_SOURCE_DIR}/ompl/src" PARENT_SCOPE)
    set(DOXYGEN_BUILTIN_STL_SUPPORT YES PARENT_SCOPE)
    set(DOXYGEN_EXTRACT_STATIC YES PARENT_SCOPE)
    set(DOXYGEN_EXTRACT_LOCAL_CLASSES NO PARENT_SCOPE)
    set(DOXYGEN_CASE_SENSE_NAMES YES PARENT_SCOPE)
    set(DOXYGEN_SORT_BY_SCOPE_NAME YES PARENT_SCOPE)
    set(DOXYGEN_FILE_PATTERNS "*.h;*.cpp;*.md;*.dox;*.py" PARENT_SCOPE)
    set(DOXYGEN_RECURSIVE YES PARENT_SCOPE)
    set(DOXYGEN_EXAMPLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../demos;${CMAKE_CURRENT_SOURCE_DIR}/markdown/code")
    set(DOXYGEN_EXAMPLE_RECURSIVE YES PARENT_SCOPE)
    set(DOXYGEN_SOURCE_BROWSER YES PARENT_SCOPE)
    set(DOXYGEN_COLS_IN_ALPHA_INDEX 3 PARENT_SCOPE)
    set(DOXYGEN_HTML_HEADER "${CMAKE_BINARY_DIR}/doc/header.html" PARENT_SCOPE)
    set(DOXYGEN_HTML_FOOTER "${CMAKE_CURRENT_SOURCE_DIR}/footer.html" PARENT_SCOPE)
    set(DOXYGEN_DOCSET_BUNDLE_ID org.kavrakilab.ompl PARENT_SCOPE)
    set(DOXYGEN_DOCSET_PUBLISHER_ID org.kavrakilab PARENT_SCOPE)
    set(DOXYGEN_DOCSET_PUBLISHER_NAME "Kavraki Lab" PARENT_SCOPE)
    set(DOXYGEN_DISABLE_INDEX YES PARENT_SCOPE)
    set(DOXYGEN_FORMULA_FONTSIZE 13 PARENT_SCOPE)
    set(DOXYGEN_USE_MATHJAX YES PARENT_SCOPE)
    set(DOXYGEN_MATHJAX_EXTENSIONS "TeX/AMSmath;TeX/AMSsymbols" PARENT_SCOPE)
    set(DOXYGEN_GENERATE_LATEX NO PARENT_SCOPE)
    set(DOXYGEN_EXTRA_PACKAGES "mathptmx,amsfonts,amsmath" PARENT_SCOPE)
    set(DOXYGEN_MACRO_EXPANSION YES PARENT_SCOPE)
    set(DOXYGEN_PREDEFINED "BOOST_VERSION=999999;OMPL_HAVE_FLANN=1" PARENT_SCOPE)
    set(DOXYGEN_COLLABORATION_GRAPH NO PARENT_SCOPE)
    set(DOXYGEN_DOT_TRANSPARENT YES PARENT_SCOPE)
    set(DOXYGEN_DOT_MULTI_TARGETS YES PARENT_SCOPE)
    set(DOXYGEN_HTML_OUTPUT "${CMAKE_BINARY_DIR}/ompl_doc")
    set(DOXYGEN_GENERATE_TAGFILE "${DOXYGEN_HTML_OUTPUT}/ompl.tag")
    doxygen_add_docs(ompl_doc
        "${CMAKE_CURRENT_SOURCE_DIR}/markdown"
        "${CMAKE_CURRENT_SOURCE_DIR}/../demos"
        "${CMAKE_CURRENT_SOURCE_DIR}/../src/ompl"
        "${CMAKE_BINARY_DIR}/doc"
        WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
    add_custom_command(TARGET ompl_doc POST_BUILD
        COMMAND cp -r ompl.css images ieee-ram-2012-ompl.pdf "${CMAKE_BINARY_DIR}/install-ompl-ubuntu.sh" "${DOXYGEN_HTML_OUTPUT}"
        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()

install(FILES man/ompl_benchmark_statistics.1 man/plannerarena.1
    DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT ompl)
